package com.ushine.design.design.c_behavioral_pattern.f_memento.b_example;

public class Client {
    public static void main(String[] args) {
        MementoCartaker cartaker = new MementoCartaker();
        Chessman chessman = new Chessman("车", 1, 1);
        display(chessman);
        cartaker.setMemento(chessman.save());

        chessman.setY(4);
        display(chessman);
        cartaker.setMemento(chessman.save());

        chessman.setX(5);
        display(chessman);
        System.out.println("*****悔棋******");
        chessman.resore(cartaker.getMemento());
        display(chessman);
    }

    public static void display(Chessman chessman) {
        System.out.println("棋子" + chessman.getLabel() + "当前位置为：" + "第" + chessman.getX()
                + "行" + "第" + chessman.getY() + "列");
    }
}
